package com.tz.colawallet.ui.activity;

import android.os.CountDownTimer;
import android.widget.ImageView;
import android.widget.TextView;

import com.tz.colawallet.R;
import com.tz.colawallet.basecode.base.BaseActivity;

public class LoadingActivity extends BaseActivity {


    TextView loadingTime;
    ImageView loadingImg1;
    ImageView loadingImg2;
    ImageView loadingImg3;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_loading;
    }

    @Override
    protected void init() {
        loadingTime = findViewById(R.id.loading_time);
        loadingImg1 = findViewById(R.id.loading_img1);
        loadingImg2 = findViewById(R.id.loading_img2);
        loadingImg3 = findViewById(R.id.loading_img3);


        CountDownTimer textTimer = new CountDownTimer(5000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                loadingTime.setText(((int) millisUntilFinished / 1000) + "S");
            }

            @Override
            public void onFinish() {
            }
        }.start();

        CountDownTimer timer = new CountDownTimer(5000, 500) {
            @Override
            public void onTick(long millisUntilFinished) {
                switch (((int) millisUntilFinished / 500) % 3) {
                    case 2:
                        loadingImg1.setImageResource(R.mipmap.rectangle3);
                        loadingImg2.setImageResource(R.mipmap.rectangle2);
                        loadingImg3.setImageResource(R.mipmap.rectangle1);
                        break;
                    case 1:
                        loadingImg1.setImageResource(R.mipmap.rectangle1);
                        loadingImg2.setImageResource(R.mipmap.rectangle3);
                        loadingImg3.setImageResource(R.mipmap.rectangle2);
                        break;
                    case 0:
                        loadingImg1.setImageResource(R.mipmap.rectangle2);
                        loadingImg2.setImageResource(R.mipmap.rectangle1);
                        loadingImg3.setImageResource(R.mipmap.rectangle3);
                        break;
                    default:
                        break;
                }
            }

            @Override
            public void onFinish() {
                switchActivity(MainActivity.class, null);
                finish();

            }
        }.start();

    }

    @Override
    protected void initTitle() {

    }

}
